package co.yixiang.modules.shop.service.impl;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
import co.yixiang.exception.BadRequestException;
import co.yixiang.exception.EntityExistException;
import co.yixiang.modules.activity.domain.YxStorePink;
import co.yixiang.modules.activity.repository.YxStorePinkRepository;
import co.yixiang.modules.shop.domain.StoreOrderCartInfo;
import co.yixiang.modules.shop.domain.YxStoreOrder;
import co.yixiang.modules.shop.domain.YxStoreOrderStatus;
import co.yixiang.modules.shop.repository.YxStoreOrderCartInfoRepository;
import co.yixiang.modules.shop.repository.YxStoreOrderRepository;
import co.yixiang.modules.shop.repository.YxUserRepository;
import co.yixiang.modules.shop.service.YxStoreOrderService;
import co.yixiang.modules.shop.service.YxStoreOrderStatusService;
import co.yixiang.modules.shop.service.YxUserBillService;
import co.yixiang.modules.shop.service.YxUserService;
import co.yixiang.modules.shop.service.dto.*;
import co.yixiang.modules.shop.service.mapper.YxStoreOrderMapper;
import co.yixiang.utils.FileUtil;
import co.yixiang.utils.OrderUtil;
import co.yixiang.utils.QueryHelp;
import co.yixiang.utils.ValidationUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.binarywang.wxpay.service.WxPayService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;

/**
* @author hupeng
* @date 2019-10-14
*/
@Slf4j
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class YxStoreOrderServiceImpl implements YxStoreOrderService {

    @Autowired
    private YxStoreOrderRepository yxStoreOrderRepository;

    @Autowired
    private YxStoreOrderCartInfoRepository yxStoreOrderCartInfoRepository;

    @Autowired
    private YxStoreOrderMapper yxStoreOrderMapper;

    @Autowired
    private YxStoreOrderStatusService yxStoreOrderStatusService;

    @Autowired
    private YxUserService userService;

    @Autowired
    private YxUserRepository userRepository;

    @Autowired
    private YxUserBillService yxUserBillService;

    @Autowired
    private YxStorePinkRepository storePinkRepository;


    @Override
    public OrderTimeDataDTO getOrderTimeData() {
        int today = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(new Date()));
        int yesterday = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(DateUtil.
                yesterday()));
        int lastWeek = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(DateUtil.lastWeek()));
        int nowMonth = OrderUtil.dateToTimestampT(DateUtil
                .beginOfMonth(new Date()));
        OrderTimeDataDTO orderTimeDataDTO = new OrderTimeDataDTO();

        orderTimeDataDTO.setTodayCount(yxStoreOrderRepository.countByPayTimeGreaterThanEqual(today));
        orderTimeDataDTO.setTodayPrice(yxStoreOrderRepository.sumPrice(today));

        orderTimeDataDTO.setProCount(yxStoreOrderRepository.countByPayTimeLessThanAndPayTimeGreaterThanEqual(today,yesterday));
        orderTimeDataDTO.setProPrice(yxStoreOrderRepository.sumTPrice(today,yesterday));

        orderTimeDataDTO.setLastWeekCount(yxStoreOrderRepository.countByPayTimeGreaterThanEqual(lastWeek));
        orderTimeDataDTO.setLastWeekPrice(yxStoreOrderRepository.sumPrice(lastWeek));

        orderTimeDataDTO.setMonthCount(yxStoreOrderRepository.countByPayTimeGreaterThanEqual(nowMonth));
        orderTimeDataDTO.setMonthPrice(yxStoreOrderRepository.sumPrice(nowMonth));

        return orderTimeDataDTO;
    }

    @Override
    public Map<String, Object> chartCount() {
        Map<String, Object> map = new LinkedHashMap<>();
        int nowMonth = OrderUtil.dateToTimestampT(DateUtil
                .beginOfMonth(new Date()));

        map.put("chart",yxStoreOrderRepository.chartList(nowMonth));
        map.put("chartT",yxStoreOrderRepository.chartListT(nowMonth));

        return map;
    }


    private JSONObject getWxRefund(String orderId) {
        String url = "https://pms.polywuye.com/oss-gateway/api/wxPay/refund";
        JSONObject requestBody = new JSONObject();
        requestBody.put("outTradeNo",orderId);
        requestBody.put("appId","wxf302b7c838a721f7");
        String responseStr = HttpRequest.post(url).body(requestBody.toJSONString()).execute().body();
        JSONObject response = JSONObject.parseObject(responseStr);
        JSONObject refundInfo;
        String exceptionCode = response.getString("exceptionCode");
        if("0".equals(exceptionCode)) {
            refundInfo = response.getJSONObject("bizContent");
        }else{
            throw new BadRequestException("微信支付退款失败。");
        }
        return refundInfo;
    }

    private JSONObject checkWxPayInfo(String orderSn){
        String url = "https://pms.polywuye.com/oss-gateway/api/wxPay/orderQuery";
        JSONObject requestBody = new JSONObject();
        requestBody.put("outTradeNo",orderSn);
        requestBody.put("appId","wxf302b7c838a721f7");


        String responseStr = HttpRequest.post(url).body(requestBody.toJSONString()).execute().body();
        JSONObject response = JSONObject.parseObject(responseStr);
        JSONObject payInfo = null;
        String exceptionCode = response.getString("exceptionCode");
        if("0".equals(exceptionCode)) {
            payInfo = response.getJSONObject("bizContent");
        }else{
            throw new BadRequestException("微信支付订单查询失败。");
        }
        return payInfo;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void refund(YxStoreOrder resources) {

        if(resources.getPayPrice().doubleValue() < 0){
            throw new BadRequestException("请输入退款金额");
        }

        JSONObject wxRefund = this.getWxRefund(resources.getOrderId());

        YxStoreOrder byId = yxStoreOrderMapper.toEntity(this.findById(resources.getId()));
        byId.setRefundInfo(wxRefund.toJSONString());
        Long time = System.currentTimeMillis()/1000L;
        byId.setRefundStatus(2);
        byId.setRefundReasonTime(time.intValue());
        byId.setRefundPrice(byId.getPayPrice());
        byId.setStatus(-1);
        byId.setRefundReasonWapExplain(resources.getRefundReasonWapExplain());
        yxStoreOrderRepository.save(byId);

        YxStoreOrderStatus storeOrderStatus = new YxStoreOrderStatus();
        storeOrderStatus.setOid(resources.getId());
        storeOrderStatus.setChangeType("refund_price");
        storeOrderStatus.setChangeMessage("退款给用户："+resources.getPayPrice() +"元，退款原因:"+resources.getRefundReasonWapExplain());
        storeOrderStatus.setChangeTime(OrderUtil.getSecondTimestampTwo());

        yxStoreOrderStatusService.create(storeOrderStatus);



//        if(resources.getPayType().equals("yue")){
//            //修改状态
//            resources.setRefundStatus(2);
//            resources.setRefundPrice(resources.getPayPrice());
//            update(resources);
//
//            //退款到余额
//            YxUserDTO userDTO = userService.findById(resources.getUid());
//            userRepository.updateMoney(resources.getPayPrice().doubleValue(),
//                    resources.getUid());
//
//            YxUserBill userBill = new YxUserBill();
//            userBill.setUid(resources.getUid());
//
//            userBill.setLinkId(resources.getId().toString());
//            userBill.setPm(1);
//            userBill.setTitle("商品退款");
//            userBill.setCategory("now_money");
//            userBill.setType("pay_product_refund");
//            userBill.setNumber(resources.getPayPrice());
//            userBill.setBalance(NumberUtil.add(resources.getPayPrice(),userDTO.getNowMoney()));
//            userBill.setMark("订单退款到余额");
//            userBill.setAddTime(OrderUtil.getSecondTimestampTwo());
//            userBill.setStatus(1);
//            yxUserBillService.create(userBill);
//
//
//
//        }else{
//            String apiUrl = RedisUtil.get("api_url");
//            if(StrUtil.isBlank(apiUrl)) throw new BadRequestException("请配置api地址");
//            //读取redis配置
//            String appId = RedisUtil.get("wxpay_appId");
//            String mchId = RedisUtil.get("wxpay_mchId");
//            String mchKey = RedisUtil.get("wxpay_mchKey");
//            String keyPath = RedisUtil.get("wxpay_keyPath");
//
//            if(StrUtil.isBlank(appId) || StrUtil.isBlank(mchId) || StrUtil.isBlank(mchKey)){
//                throw new BadRequestException("请配置微信支付");
//            }
//            if(StrUtil.isBlank(keyPath)){
//                throw new BadRequestException("请配置微信支付证书");
//            }
//            WxPayRefundRequest wxPayRefundRequest = new WxPayRefundRequest();
//            BigDecimal bigDecimal = new BigDecimal("100");
//            wxPayRefundRequest.setTotalFee(bigDecimal.multiply(resources.getPayPrice()).intValue());//订单总金额
//            wxPayRefundRequest.setOutTradeNo(resources.getOrderId());
//            wxPayRefundRequest.setOutRefundNo(resources.getOrderId());
//            wxPayRefundRequest.setRefundFee(bigDecimal.multiply(resources.getPayPrice()).intValue());//退款金额
//            wxPayRefundRequest.setOpUserId(mchId); //操作人默认商户号当前
//            wxPayRefundRequest.setNotifyUrl(apiUrl+"/api/notify/refund");
//
//            WxPayConfig wxPayConfig = new WxPayConfig();
//            wxPayConfig.setAppId(appId);
//            wxPayConfig.setMchId(mchId);
//            wxPayConfig.setMchKey(mchKey);
//            wxPayConfig.setKeyPath(keyPath);
//            wxPayService.setConfig(wxPayConfig);
//            try {
//                wxPayService.refund(wxPayRefundRequest);
//            } catch (WxPayException e) {
//                log.info("refund-error:{}",e.getMessage());
//            }
//        }


    }

    @Override
    public String orderType(int id,int pinkId, int combinationId,int seckillId) {
        String str = "[普通订单]";
        if(pinkId > 0 || combinationId > 0){
            YxStorePink storePink = storePinkRepository.findByOrderIdKey(id);
            if(ObjectUtil.isNull(storePink)) {
                str = "[拼团订单]";
            }else{
                switch (storePink.getStatus()){
                    case 1:
                        str = "[拼团订单]正在进行中";
                        break;
                    case 2:
                        str = "[拼团订单]已完成";
                        break;
                    case 3:
                        str = "[拼团订单]未完成";
                        break;
                    default:
                        str = "[拼团订单]历史订单";
                        break;
                }
            }

        }else if(seckillId > 0){
            str = "[秒杀订单]";
        }
        return str;
    }

    @Override
    public Map<String,Object> queryAll(YxStoreOrderQueryCriteria criteria, Pageable pageable){

        Page<YxStoreOrder> page = yxStoreOrderRepository
                .findAll((root, criteriaQuery, criteriaBuilder)
                        -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);

        List<YxStoreOrderDTO> storeOrderDTOS = new ArrayList<>();
        for (YxStoreOrder yxStoreOrder : page.getContent()) {
            YxStoreOrderDTO yxStoreOrderDTO = yxStoreOrderMapper.toDto(yxStoreOrder);


            Integer _status = OrderUtil.orderStatus(yxStoreOrder.getPaid(),yxStoreOrder.getStatus(),
                    yxStoreOrder.getRefundStatus());

            //订单状态
            String orderStatusStr = OrderUtil.orderStatusStr(yxStoreOrder.getPaid()
                    ,yxStoreOrder.getStatus(),yxStoreOrder.getShippingType()
                    ,yxStoreOrder.getRefundStatus());

            if(_status == 3){
                String refundTime = OrderUtil.stampToDate(String.valueOf(yxStoreOrder
                        .getRefundReasonTime()));
                String str = "<b style='color:#f124c7'>申请退款</b><br/>"+
                        "<span>退款原因："+yxStoreOrder.getRefundReasonWap()+"</span><br/>" +
                        "<span>备注说明："+yxStoreOrder.getRefundReasonWapExplain()+"</span><br/>" +
                        "<span>退款时间："+refundTime+"</span><br/>";
                orderStatusStr = str;
            }
            yxStoreOrderDTO.setStatusName(orderStatusStr);

            yxStoreOrderDTO.set_status(_status);

            String payTypeName = OrderUtil.payTypeName(yxStoreOrder.getPayType()
                    ,yxStoreOrder.getPaid());
            yxStoreOrderDTO.setPayTypeName(payTypeName);

            yxStoreOrderDTO.setPinkName(orderType(yxStoreOrder.getId()
                    ,yxStoreOrder.getPinkId(),yxStoreOrder.getCombinationId()
                    ,yxStoreOrder.getSeckillId()));

            List<StoreOrderCartInfo> cartInfos = yxStoreOrderCartInfoRepository.findByOid(yxStoreOrder.getId());
            List<StoreOrderCartInfoDTO> cartInfoDTOS = new ArrayList<>();
            for (StoreOrderCartInfo cartInfo : cartInfos) {
                StoreOrderCartInfoDTO cartInfoDTO = new StoreOrderCartInfoDTO();
                cartInfoDTO.setCartInfoMap(JSON.parseObject(cartInfo.getCartInfo()));
                cartInfoDTOS.add(cartInfoDTO);
            }

            yxStoreOrderDTO.setCartInfoList(cartInfoDTOS);
            storeOrderDTOS.add(yxStoreOrderDTO);

        }

        Map<String,Object> map = new LinkedHashMap<>(2);
        map.put("content",storeOrderDTOS);
        map.put("totalElements",page.getTotalElements());

        return map;
    }

    @Override
    public List<YxStoreOrderDTO> queryAll(YxStoreOrderQueryCriteria criteria){
        return yxStoreOrderMapper.toDto(yxStoreOrderRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
    }

    @Override
    public YxStoreOrderDTO findById(Integer id) {
        Optional<YxStoreOrder> yxStoreOrder = yxStoreOrderRepository.findById(id);
        ValidationUtil.isNull(yxStoreOrder,"YxStoreOrder","id",id);
        return yxStoreOrderMapper.toDto(yxStoreOrder.get());
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public YxStoreOrderDTO create(YxStoreOrder resources) {
        if(yxStoreOrderRepository.findByUnique(resources.getUnique()) != null){
            throw new EntityExistException(YxStoreOrder.class,"unique",resources.getUnique());
        }
        return yxStoreOrderMapper.toDto(yxStoreOrderRepository.save(resources));
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(YxStoreOrder resources) {
        Optional<YxStoreOrder> optionalYxStoreOrder = yxStoreOrderRepository.findById(resources.getId());
        ValidationUtil.isNull( optionalYxStoreOrder,"YxStoreOrder","id",resources.getId());
        YxStoreOrder yxStoreOrder = optionalYxStoreOrder.get();
        YxStoreOrder yxStoreOrder1 = yxStoreOrderRepository.findByUnique(resources.getUnique());
        if(yxStoreOrder1 != null && !yxStoreOrder1.getId().equals(yxStoreOrder.getId())){
            throw new EntityExistException(YxStoreOrder.class,"unique",resources.getUnique());
        }
        yxStoreOrder.copy(resources);
        yxStoreOrderRepository.save(yxStoreOrder);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delete(Integer id) {
        yxStoreOrderRepository.deleteById(id);
    }

    @Override
    public void changeStatusByTask(Integer time) {
        if(time == null || time <= 0) time = 15;
        Long curTime = (System.currentTimeMillis()/1000L) - (time * 60L);
        if(curTime > 0){
            List<YxStoreOrder> list = yxStoreOrderRepository.findByAddTimeLessThanEqualAndPaidAndIsDelAndStatus(curTime.intValue(), 0, 0,0);
            if(list != null && list.size() > 0){
                for (YxStoreOrder yxStoreOrder : list) {
                    JSONObject payInfo = checkWxPayInfo(yxStoreOrder.getOrderId());

                    YxStoreOrderStatus storeOrderStatus = new YxStoreOrderStatus();
                    storeOrderStatus.setOid(yxStoreOrder.getId());
                    storeOrderStatus.setChangeType("system_auto_cancel");
                    storeOrderStatus.setChangeMessage("系统自动取消");
                    storeOrderStatus.setChangeTime(OrderUtil.getSecondTimestampTwo());
                    yxStoreOrderStatusService.create(storeOrderStatus);

                    yxStoreOrder.setStatus(-99);
                    yxStoreOrder.setTransInfo(payInfo.toJSONString());
                    this.update(yxStoreOrder);
                }
            }
        }
    }


    @Override
    public void confirmOrderByTask(Integer day) {
        if(day == null || day <= 0) day = 15;
        Long curTime = (System.currentTimeMillis()/1000L) - (day * 24 * 60 * 60L);
        List<YxStoreOrder> list = yxStoreOrderRepository.findByDeliveryGoodsTime(curTime.intValue());
        if(list != null && list.size() >0){
            for (YxStoreOrder yxStoreOrder : list) {

                YxStoreOrderStatus storeOrderStatus = new YxStoreOrderStatus();
                storeOrderStatus.setOid(yxStoreOrder.getId());
                storeOrderStatus.setChangeType("user_take_delivery");
                storeOrderStatus.setChangeMessage("用户已收货");
                storeOrderStatus.setChangeTime(OrderUtil.getSecondTimestampTwo());
                yxStoreOrderStatusService.create(storeOrderStatus);

                yxStoreOrder.setStatus(2);
                this.update(yxStoreOrder);
            }

        }
    }

    @Override
    public void getPayInfoTask(){
        List<YxStoreOrder> list = yxStoreOrderRepository.findByPaidAndTransIdIsNull(1);
        if(list != null && list.size() > 0){
            list.forEach(order->{
                JSONObject payInfo = this.checkWxPayInfo(order.getOrderId());
                if(payInfo != null){
                    String transId = payInfo.getString("transaction_id");
                    order.setTransId(transId);
                    order.setTransInfo(payInfo.toJSONString());
                }
                this.update(order);
            });
        }
    }

    @Override
    public void download(List<YxStoreOrderDTO> all, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
        for (YxStoreOrderDTO yxStoreOrder : all) {
            Map<String,Object> map = new LinkedHashMap<>();
            map.put("订单号", yxStoreOrder.getOrderId());
//            map.put("用户id", yxStoreOrder.getUid());
            YxUserDTO userDTO = userService.findById(yxStoreOrder.getUid());
            map.put("用户手机码", userDTO.getPhone());
            map.put("收货人姓名", yxStoreOrder.getRealName());
            map.put("收货人电话", yxStoreOrder.getUserPhone());
            map.put("收货详细地址", yxStoreOrder.getUserAddress());
//            map.put("购物车id", yxStoreOrder.getCartId());
//            map.put("运费金额", yxStoreOrder.getFreightPrice());


            List<StoreOrderCartInfo> cartInfos = yxStoreOrderCartInfoRepository.findByOid(yxStoreOrder.getId());
            StringBuilder goods = new StringBuilder();
            String supplierName = "";
            for (StoreOrderCartInfo cartInfo : cartInfos) {
                JSONObject jsonObject = JSON.parseObject(cartInfo.getCartInfo());
                JSONObject productInfo = jsonObject.getJSONObject("productInfo");
                String storeName = productInfo.getString("storeName");
                goods.append(storeName).append(" x ").append(jsonObject.getInteger("cartNum")).append("\n");
                supplierName = productInfo.getString("supplierName");
            }

            map.put("供应商",supplierName);
            map.put("商品",goods.toString());

            map.put("订单商品总数", yxStoreOrder.getTotalNum());
            map.put("订单总价(元)", yxStoreOrder.getTotalPrice());
//            map.put("邮费", yxStoreOrder.getTotalPostage());
            map.put("实际支付金额(元)", yxStoreOrder.getPayPrice());
//            map.put("支付邮费", yxStoreOrder.getPayPostage());
//            map.put("抵扣金额", yxStoreOrder.getDeductionPrice());
//            map.put("优惠券id", yxStoreOrder.getCouponId());
//            map.put("优惠券金额", yxStoreOrder.getCouponPrice());
            map.put("支付状态", yxStoreOrder.getPaid() == 1 ? "已支付" : "未支付");
            String payTime = null;
            if(yxStoreOrder.getPayTime() != null && yxStoreOrder.getPayTime() > 0){
                payTime = DateUtil.format(DateUtil.date(yxStoreOrder.getPayTime() * 1000L), DatePattern.NORM_DATETIME_FORMAT);
            }
            map.put("支付时间", payTime);

            map.put("支付方式", OrderUtil.payTypeName(yxStoreOrder.getPayType(),yxStoreOrder.getPaid()));
            String addTime = null;
            if(yxStoreOrder.getAddTime() != null && yxStoreOrder.getAddTime() > 0){
                addTime = DateUtil.format(DateUtil.date(yxStoreOrder.getAddTime() * 1000L), DatePattern.NORM_DATETIME_FORMAT);
            }
            map.put("创建时间", addTime);
            map.put("订单状态", OrderUtil.orderStatusStr(yxStoreOrder.getPaid() ,yxStoreOrder.getStatus(),yxStoreOrder.getShippingType() ,yxStoreOrder.getRefundStatus()));
//            map.put("0 未退款 1 申请中 2 已退款", yxStoreOrder.getRefundStatus());
//            map.put("退款图片", yxStoreOrder.getRefundReasonWapImg());
//            map.put("退款用户说明", yxStoreOrder.getRefundReasonWapExplain());
//            map.put("退款时间", yxStoreOrder.getRefundReasonTime());
//            map.put("前台退款原因", yxStoreOrder.getRefundReasonWap());
//            map.put("不退款的理由", yxStoreOrder.getRefundReason());
//            map.put("退款金额", yxStoreOrder.getRefundPrice());
//            map.put("快递公司编号", yxStoreOrder.getDeliveryId());
            map.put("快递名称", yxStoreOrder.getDeliveryName());
            map.put("发货类型", yxStoreOrder.getDeliveryType());
            map.put("快递单号", yxStoreOrder.getDeliveryId());
//            map.put("消费赚取积分", yxStoreOrder.getGainIntegral());
//            map.put("使用积分", yxStoreOrder.getUseIntegral());
//            map.put("给用户退了多少积分", yxStoreOrder.getBackIntegral());
            map.put("订单备注", yxStoreOrder.getMark());
//            map.put("是否删除", yxStoreOrder.getIsDel());
//            map.put("唯一id(md5加密)类似id", yxStoreOrder.getUnique());
            map.put("管理员备注", yxStoreOrder.getRemark());
//            map.put("商户ID", yxStoreOrder.getMerId());
//            map.put(" isMerCheck",  yxStoreOrder.getIsMerCheck());
//            map.put("拼团产品id0一般产品", yxStoreOrder.getCombinationId());
//            map.put("拼团id 0没有拼团", yxStoreOrder.getPinkId());
//            map.put("成本价", yxStoreOrder.getCost());
//            map.put("秒杀产品ID", yxStoreOrder.getSeckillId());
//            map.put("砍价id", yxStoreOrder.getBargainId());
//            map.put("核销码", yxStoreOrder.getVerifyCode());
//            map.put("门店id", yxStoreOrder.getStoreId());
//            map.put("配送方式 1=快递 ，2=门店自提", yxStoreOrder.getShippingType());
//            map.put("支付渠道(0微信公众号1微信小程序)", yxStoreOrder.getIsChannel());
//            map.put(" isRemind",  yxStoreOrder.getIsRemind());
//            map.put(" isSystemDel",  yxStoreOrder.getIsSystemDel());
            map.put("交易号",yxStoreOrder.getTransId());
            list.add(map);
        }
        FileUtil.downloadExcel(list, response);
    }
}